Count Enumerations

Are there any scripts out there that count how many times an enumerated value is set in the module?  I have a list of 40 enumerations and would like to show how many times each one has been set.


vppatel - Wed Dec 04 13:10:56 EST 2013

Re: Count Enumerations
GregM_dxler - Wed Dec 04 15:50:45 EST 2013

Hi,

I started out by looking at a bruteforce method of defining each of the attribute enumerations and then decided to try and make it smart and let it determine how many enumerations there are.  This should get you most of the way.  If your really smart, you would add in a dialog box to select which attribute you want to use.

Hope this helps,
Greg

//Counts the number of objects in the display set that is allocated to each enumerated value for an attribute
pragma runLim, 0 //Don't timeout

const string AttrName = "Program Specific" //enumerated attribute name to use
Object curobj
Module curmod = current

//get number of enumerations for attribute
int enumCount = 0

AttrType at = null
at = find(curmod, AttrName)
if (null at) {
   warningBox("No attribute by the name " AttrName "")
   halt
}
else if (at.type "" != "Enumeration") {
   warningBox("Attribute " AttrName " is not an enumeration")
   halt
}
else {
   enumCount = at.size
}
if (enumCount == 0) {
   warningBox("Attribute " AttrName " has no enumerations")
   halt
}
//define arrays for enumeration and count of each enumeration type
string EnumValue[enumCount]
int NumberOfObjects[enumCount]
int index
for (index = 0; index < enumCount; index++) {
   EnumValue[index] = at.strings[index]
   NumberOfObjects[index] = 0
}
//loop through objects and count
for curobj in entire curmod do {
   if (null curobj) continue //skip if not found
   if (isDeleted curobj) continue //skip if deleted
  
   for (index = 0; index < enumCount; index++) {
      if (isMember(curobj.AttrName, EnumValue[index])) NumberOfObjects[index]++
   }
}
for (index = 0; index < enumCount; index++) {
   print "Number of objects allocated to " EnumValue[index] " = " NumberOfObjects[index] "\n"
}
print "done"

Re: Count Enumerations
vppatel - Mon Dec 09 12:28:02 EST 2013

GregM_dxler - Wed Dec 04 15:50:45 EST 2013

Hi,

I started out by looking at a bruteforce method of defining each of the attribute enumerations and then decided to try and make it smart and let it determine how many enumerations there are.  This should get you most of the way.  If your really smart, you would add in a dialog box to select which attribute you want to use.

Hope this helps,
Greg

//Counts the number of objects in the display set that is allocated to each enumerated value for an attribute
pragma runLim, 0 //Don't timeout

const string AttrName = "Program Specific" //enumerated attribute name to use
Object curobj
Module curmod = current

//get number of enumerations for attribute
int enumCount = 0

AttrType at = null
at = find(curmod, AttrName)
if (null at) {
   warningBox("No attribute by the name " AttrName "")
   halt
}
else if (at.type "" != "Enumeration") {
   warningBox("Attribute " AttrName " is not an enumeration")
   halt
}
else {
   enumCount = at.size
}
if (enumCount == 0) {
   warningBox("Attribute " AttrName " has no enumerations")
   halt
}
//define arrays for enumeration and count of each enumeration type
string EnumValue[enumCount]
int NumberOfObjects[enumCount]
int index
for (index = 0; index < enumCount; index++) {
   EnumValue[index] = at.strings[index]
   NumberOfObjects[index] = 0
}
//loop through objects and count
for curobj in entire curmod do {
   if (null curobj) continue //skip if not found
   if (isDeleted curobj) continue //skip if deleted
  
   for (index = 0; index < enumCount; index++) {
      if (isMember(curobj.AttrName, EnumValue[index])) NumberOfObjects[index]++
   }
}
for (index = 0; index < enumCount; index++) {
   print "Number of objects allocated to " EnumValue[index] " = " NumberOfObjects[index] "\n"
}
print "done"

Thanks for the help, will try it out and modify accordingly.

 

Regards